﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using InformationSystem.BLL.Core.Model;
using Ext.Net;
using InformationSystem.BLL.Core.Service;

namespace InformationSystem.WebSite
{
    public partial class _Default : BasePage
    {

        protected LoginUser user;
        protected string unreadmailcount = "";
        public IInformationService InformationService { get; set; }
        public ISharedDocumentService SharedDocumentService { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            user = (LoginUser)Session["LoginUser"];
            lastlogintime.InnerText = string.Format("最后登录时间:{0}", user.LastLoginDateTime.ToString("yyyy/MM/dd HH:mm"));
            //查询当前用户关联信息

            //获取未读邮件数量
            int count = InformationService.GetMailUnreadCount(user);
            unreadmailcount = count == 0 ? "" : string.Format("[{0}]", count);
            //获取公告
            IList<Affiche> affichelist = InformationService.GetRecvAfficheList(user, 11);
            AfficheStore.DataSource = affichelist;
            AfficheStore.DataBind();
            //获取就业信息
            IList<WorkInfo> workinfolist = InformationService.GetRecvWorkInfoList(user, 11);
            WorkStore.DataSource = workinfolist;
            WorkStore.DataBind();
            //获取消息
            IList<Msg> msgList = InformationService.GetMsgRecvList(user.UserID, 11);
            MsgStore.DataSource = msgList;
            MsgStore.DataBind();
            //获取共享文档
            IList<FileInformation> filelist = SharedDocumentService.GetDocuments(user, 11);
            DocStore.DataSource = filelist;
            DocStore.DataBind();
            taskmgr.Tasks[0].Interval = (int)Application[Common.ClientRefreshSpan];
        }

        protected void LogOut_Click(object sender, DirectEventArgs e)
        {
            Session["LoginUser"] = null;
            Response.Redirect("Login.aspx");
        }

        protected override bool CommitPermissionCheck()
        {
            return true;
        }
    }
}
